# Check whether number is prime
# Author: shanmugs1@gmail.com

use strict;

my $n = shift || die "Usage: $0 <n>\n";

die "$n is prime.\n" if ($n == 1 || $n == 2);
die "?\n" if ($n < 1);

for (my $i = 2; $i <= sqrt($n); $i++) {
    if ($n % $i == 0) {
	die "$n is not a prime.\n";
    }
}

print "$n is prime.\n";
